package com.klangner.go.model;


/**
 * This class represents move. Move consists of position and stone color.
 * Move can also be PASS.
 * 
 * @author Krzysztof Langner
 */
public class Move extends BoardPosition{
	
	/** move color */
	private int	color;
	/** is pass */
	private boolean pass;

	/**
	 * empty constructor means PASS
	 */
	public Move(int color) {
		super(-1, -1);
		pass = true;
		this.color = color;
	}

	/**
	 * constructor
	 * @param x
	 * @param y
	 * @param color
	 */
	public Move(int x, int y, int color) {
		super(x, y);

		this.color = color;
    pass = false;
	}
	
	
	/**
	 * @return color
	 */
	public int getColor(){
		return color;
	}
	
  /**
   * compare objects
   */
	public boolean equals(Move move) {

		if(move.isPass() && isPass()){
			return true;
		}
		else if( super.equals(move) && move.color == color){
			return true;
		}
		
		return false;
	}

  /**
   * @return true if this move is pass
   */
	public boolean isPass() {
		return pass;
	}
	
	/**
	 * convert to string
	 */
	public String toString() {
		String text;
		
		if(pass)
			text = "pass";
		else
			text = super.toString() + color;
		
		return text;
	}
}
